package com.xiao.permission_system.mapper;

import com.xiao.permission_system.entity.Role;
import com.xiao.permission_system.entity.UserInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiao.permission_system.entityvo.RoleVO;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import cn.xiao.permission_system.common.MyMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author beth
 * @since 2019-10-26
 */
@Repository
public interface UserInfoMapper extends MyMapper<UserInfo> {
     /**
      * 分页查询
      * @param page 分页信息
      * @param wrapper 查询条件
      * @return
      */
      IPage<UserInfo> selectPage(Page<UserInfo> page, @Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);

      List<UserInfo> selectAll(@Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);

      @Select("select * from user ${ew.customSqlSegment}")
      List<UserInfo> mySelect(@Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);

      /**
       * 删除所有
       * @return
       */
      int deleteAll();

     // @Select("select * from sys_user_info u  LEFT JOIN sys_uer_role ur ON u.id=ur.uid LEFT JOIN sys_role r ON r.id= ur.role_id where u.id=#{id}")
      List<RoleVO> getRoles(String userId);
}
